<!DOCTYPE html>

<html>
<head>
<meta charset="UTF-8">
<link href="style.css" type="text/css" rel="stylesheet">
<title>FDIV/FDIVP/FIDIV—Divide </title></head>
<body>
<h1>FDIV/FDIVP/FIDIV—Divide</h1>
<table>
<tr>
<th>Opcode</th>
<th>Instruction</th>
<th>64-Bit Mode</th>
<th>Compat/Leg Mode</th>
<th>Description</th></tr>
<tr>
<td>D8 /6</td>
<td>FDIV <em>m32fp</em></td>
<td>Valid</td>
<td>Valid</td>
<td>Divide ST(0) by <em>m32fp</em> and store result in ST(0).</td></tr>
<tr>
<td>DC /6</td>
<td>FDIV <em>m64fp</em></td>
<td>Valid</td>
<td>Valid</td>
<td>Divide ST(0) by <em>m64fp</em> and store result in ST(0).</td></tr>
<tr>
<td>D8 F0+i</td>
<td>FDIV ST(0), ST(i)</td>
<td>Valid</td>
<td>Valid</td>
<td>Divide ST(0) by ST(i) and store result in ST(0).</td></tr>
<tr>
<td>DC F8+i</td>
<td>FDIV ST(i), ST(0)</td>
<td>Valid</td>
<td>Valid</td>
<td>Divide ST(i) by ST(0) and store result in ST(i).</td></tr>
<tr>
<td>DE F8+i</td>
<td>FDIVP ST(i), ST(0)</td>
<td>Valid</td>
<td>Valid</td>
<td>Divide ST(i) by ST(0), store result in ST(i), and pop the register stack.</td></tr>
<tr>
<td>DE F9</td>
<td>FDIVP</td>
<td>Valid</td>
<td>Valid</td>
<td>Divide ST(1) by ST(0), store result in ST(1), and pop the register stack.</td></tr>
<tr>
<td>DA /6</td>
<td>FIDIV <em>m32int</em></td>
<td>Valid</td>
<td>Valid</td>
<td>Divide ST(0) by <em>m32int</em> and store result in ST(0).</td></tr>
<tr>
<td>DE /6</td>
<td>FIDIV <em>m16int</em></td>
<td>Valid</td>
<td>Valid</td>
<td>Divide ST(0) by <em>m16int</em> and store result in ST(0).</td></tr></table>
<h2>Description</h2>
<p>Divides the destination operand by the source operand and stores the result in the destination location. The desti-nation operand (dividend) is always in an FPU register; the source operand (divisor) can be a register or a memory location. Source operands in memory can be in single-precision or double-precision floating-point format, word or doubleword integer format.</p>
<p>The no-operand version of the instruction divides the contents of the ST(1) register by the contents of the ST(0) register. The one-operand version divides the contents of the ST(0) register by the contents of a memory location (either a floating-point or an integer value). The two-operand version, divides the contents of the ST(0) register by the contents of the ST(i) register or vice versa.</p>
<p>The FDIVP instructions perform the additional operation of popping the FPU register stack after storing the result. To pop the register stack, the processor marks the ST(0) register as empty and increments the stack pointer (TOP) by 1. The no-operand version of the floating-point divide instructions always results in the register stack being popped. In some assemblers, the mnemonic for this instruction is FDIV rather than FDIVP.</p>
<p>The FIDIV instructions convert an integer source operand to double extended-precision floating-point format before performing the division. When the source operand is an integer 0, it is treated as a +0.</p>
<p>If an unmasked divide-by-zero exception (#Z) is generated, no result is stored; if the exception is masked, an ∞ of the appropriate sign is stored in the destination operand.</p>
<p>The following table shows the results obtained when dividing various classes of numbers, assuming that neither overflow nor underflow occurs.</p>
<h3>Table 3-24.  FDIV/FDIVP/FIDIV Results</h3>
<p><strong>DEST</strong></p>
<p>− ∞</p>
<p>− F</p>
<p>− 0</p>
<p>+ 0</p>
<p>+ F</p>
<p>+ ∞</p>
<p>NaN</p>
<p>− ∞</p>
<p>+ 0</p>
<p>+ 0</p>
<p>− 0</p>
<p>− 0</p>
<p>*</p>
<p>*</p>
<p>NaN</p>
<p>− F</p>
<p>+ ∞</p>
<p>+ F</p>
<p>+ 0</p>
<p>− 0</p>
<p>− F</p>
<p>− ∞</p>
<p>NaN</p>
<p>− I</p>
<p>+ ∞</p>
<p>+ F</p>
<p>+ 0</p>
<p>− 0</p>
<p>− F</p>
<p>− ∞</p>
<p>NaN</p>
<p>− 0</p>
<p>+ ∞</p>
<p>− ∞</p>
<p><strong>SRC</strong></p>
<p>**</p>
<p>*</p>
<p>*</p>
<p>**</p>
<p>NaN</p>
<p>+ 0</p>
<p>− ∞</p>
<p>+ ∞</p>
<p>**</p>
<p>*</p>
<p>*</p>
<p>**</p>
<p>NaN</p>
<p>+ I</p>
<p>− ∞</p>
<p>− F</p>
<p>− 0</p>
<p>+ 0</p>
<p>+ F</p>
<p>+ ∞</p>
<p>NaN</p>
<p>+ F</p>
<p>− ∞</p>
<p>− F</p>
<p>− 0</p>
<p>+ 0</p>
<p>+ F</p>
<p>+ ∞</p>
<p>NaN</p>
<p>+ ∞</p>
<p>− 0</p>
<p>− 0</p>
<p>+ 0</p>
<p>+ 0</p>
<p>*</p>
<p>*</p>
<p>NaN</p>
<p>NaN</p>
<p>NaN</p>
<p>NaN</p>
<p>NaN</p>
<p>NaN</p>
<p>NaN</p>
<p>NaN</p>
<p>NaN</p>
<p><strong>NOTES:</strong></p>
<p>F Means finite floating-point value.</p>
<p>I</p>
<p>Means integer.</p>
<p>*</p>
<p>Indicates floating-point invalid-arithmetic-operand (#IA) exception.</p>
<p>** Indicates floating-point zero-divide (#Z) exception.</p>
<p>This instruction’s operation is the same in non-64-bit modes and 64-bit mode.</p>
<h2>Operation</h2>
<pre>IF SRC = 0
    THEN
         #Z;
    ELSE
         IF Instruction is FIDIV
              THEN
                    DEST ← DEST / ConvertToDoubleExtendedPrecisionFP(SRC);
              ELSE (* Source operand is floating-point value *)
                    DEST ← DEST / SRC;
         FI;
FI;
IF Instruction = FDIVP
    THEN
         PopRegisterStack;
FI;</pre>
<h2>FPU Flags Affected</h2>
<table class="exception-table">
<tr>
<td>C1</td>
<td>
<p>Set to 0 if stack underflow occurred.</p>
<p>Set if result was rounded up; cleared otherwise.</p></td></tr>
<tr>
<td>C0, C2, C3</td>
<td>Undefined.</td></tr></table>
<h2>Floating-Point Exceptions</h2>
<table class="exception-table">
<tr>
<td>#IS</td>
<td>Stack underflow occurred.</td></tr>
<tr>
<td>#IA</td>
<td>
<p>Operand is an SNaN value or unsupported format.</p>
<p>±∞ / ±∞; ±0 / ±0</p></td></tr></table>
<p>#D</p>
<p>Source is a denormal value.</p>
<p>#Z</p>
<p>DEST / ±0, where DEST is not equal to ±0.</p>
<p>#U</p>
<p>Result is too small for destination format.</p>
<p>#O</p>
<p>Result is too large for destination format.</p>
<p>#P</p>
<p>Value cannot be represented exactly in destination format.</p>
<h2>Protected Mode Exceptions</h2>
<table class="exception-table">
<tr>
<td>#GP(0)</td>
<td>
<p>If a memory operand effective address is outside the CS, DS, ES, FS, or GS segment limit.</p>
<p>If the DS, ES, FS, or GS register contains a NULL segment selector.</p></td></tr>
<tr>
<td>#SS(0)</td>
<td>If a memory operand effective address is outside the SS segment limit.</td></tr>
<tr>
<td>#NM</td>
<td>CR0.EM[bit 2] or CR0.TS[bit 3] = 1.</td></tr>
<tr>
<td>#PF(fault-code)</td>
<td>If a page fault occurs.</td></tr>
<tr>
<td>#AC(0)</td>
<td>If alignment checking is enabled and an unaligned memory reference is made while the current privilege level is 3.</td></tr>
<tr>
<td>#UD</td>
<td>If the LOCK prefix is used.</td></tr></table>
<h2>Real-Address Mode Exceptions</h2>
<table class="exception-table">
<tr>
<td>#GP</td>
<td>If a memory operand effective address is outside the CS, DS, ES, FS, or GS segment limit.</td></tr>
<tr>
<td>#SS</td>
<td>If a memory operand effective address is outside the SS segment limit.</td></tr>
<tr>
<td>#NM</td>
<td>CR0.EM[bit 2] or CR0.TS[bit 3] = 1.</td></tr>
<tr>
<td>#UD</td>
<td>If the LOCK prefix is used.</td></tr></table>
<h2>Virtual-8086 Mode Exceptions</h2>
<table class="exception-table">
<tr>
<td>#GP(0)</td>
<td>If a memory operand effective address is outside the CS, DS, ES, FS, or GS segment limit.</td></tr>
<tr>
<td>#SS(0)</td>
<td>If a memory operand effective address is outside the SS segment limit.</td></tr>
<tr>
<td>#NM</td>
<td>CR0.EM[bit 2] or CR0.TS[bit 3] = 1.</td></tr>
<tr>
<td>#PF(fault-code)</td>
<td>If a page fault occurs.</td></tr>
<tr>
<td>#AC(0)</td>
<td>If alignment checking is enabled and an unaligned memory reference is made.</td></tr>
<tr>
<td>#UD</td>
<td>If the LOCK prefix is used.</td></tr></table>
<h2>Compatibility Mode Exceptions</h2>
<p>Same exceptions as in protected mode.</p>
<h2>64-Bit Mode Exceptions</h2>
<table class="exception-table">
<tr>
<td>#SS(0)</td>
<td>If a memory address referencing the SS segment is in a non-canonical form.</td></tr>
<tr>
<td>#GP(0)</td>
<td>If the memory address is in a non-canonical form.</td></tr>
<tr>
<td>#NM</td>
<td>CR0.EM[bit 2] or CR0.TS[bit 3] = 1.</td></tr>
<tr>
<td>#MF</td>
<td>If there is a pending x87 FPU exception.</td></tr>
<tr>
<td>#PF(fault-code)</td>
<td>If a page fault occurs.</td></tr>
<tr>
<td>#AC(0)</td>
<td>If alignment checking is enabled and an unaligned memory reference is made while the current privilege level is 3.</td></tr>
<tr>
<td>#UD</td>
<td>If the LOCK prefix is used.</td></tr></table></body></html>